{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/1.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这是一个矩阵，单个数字和矩阵相乘很简单，只要数值分别和数组中的每个元素相乘就可以了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/2.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们将数字（上面例子中的“2”）称为标量，因此这种标量与数组相乘被称为“标量乘法”。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "但如果我们用一个矩阵乘以另一个矩阵，就不是“标量乘法”了，而是需要执行一种称为“点积”的乘法操作，这是什么意思呢？让我们看一个例子："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/3.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "vscode": {
     "languageId": "plaintext"
    }
   },
   "outputs": [],
   "source": [
    "(1, 2, 3) • (8, 10, 12) = 1×8 + 2×10 + 3×12 \n",
    "    = 64\n",
    "(4, 5, 6) • (7, 9, 11) = 4×7 + 5×9 + 6×11 \n",
    "    = 139\n",
    "(4, 5, 6) • (8, 10, 12) = 4×8 + 5×10 + 6×12\n",
    "    = 154"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/4.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为什么这样做？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这种乘法方式似乎非常的奇怪、复杂，但它却是非常必要的，因为生活中确实存在这样的问题，比如："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/5.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "行和列"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为了显示一个矩阵有多少行和列，我们经常写rows x columns，比如："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/6.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "当我们做矩阵乘法时，第一个矩阵的列数必须等于第二个矩阵的行数，结果将具有与第一个矩阵相同的行数和第二个矩阵相同的列数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/7.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "所以将3x1乘以1x3将得到3x3的结果。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](img/8.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "下次，我们将介绍numpy中的点积Dot product，所以这次先介绍下什么是矩阵相乘。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "vscode": {
     "languageId": "plaintext"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
